home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 April / macformat-023.iso / Demos / MF23 / Sources of Faith / Shared.Dxr / Shared.Dxr / 00457.ls < prev    next >
Encoding:
Text File  |  1994-10-18  |  11.4 KB  |  429 lines

  1. on highlighter
  2.   global Subject, religion
  3.   set subjectCount to the height of sprite 19 / 8
  4.   set subjectNum to (the mouseV - the top of sprite 19) / subjectCount
  5.   if subjectNum >= 8 then
  6.     set subjectNum to 8
  7.   end if
  8.   set the locV of sprite 20 to the top of sprite 19 + (subjectCount * subjectNum) + subjectNum
  9.   set Subject to ChooseSubject(subjectNum)
  10.   put religion & Subject into field "store"
  11. end
  12.  
  13. on divideMe
  14.   global religion, Subject
  15.   set religionNum to (the mouseH - the left of sprite 18) / 78
  16.   if (religionNum = 5) or (religionNum < 1) then
  17.     if religionNum > 7 then
  18.       set religionNum to 7
  19.     end if
  20.     set sprtH to the left of sprite 18 + (78 * religionNum) + (the width of sprite 19 / 2) - 9
  21.     set the locH of sprite 19 to sprtH
  22.     set religion to ChooseReligion(religionNum)
  23.     repeat while the stillDown
  24.       if the mouseV >= 396 then
  25.         set Subject to "bla"
  26.         set the castNum of sprite 20 to 451
  27.         set the foreColor of sprite 20 to 249
  28.         set the width of sprite 20 to 73
  29.         set the height of sprite 20 to 73
  30.         set the locV of sprite 20 to 403
  31.         set the locV of sprite 19 to 202
  32.         set the locH of sprite 20 to the locH of sprite 19 - 35
  33.       else
  34.         highlighter()
  35.         set the castNum of sprite 20 to 511
  36.         set the foreColor of sprite 20 to 249
  37.         set the width of sprite 20 to 67
  38.         set the height of sprite 20 to 48
  39.         set the locH of sprite 20 to the locH of sprite 19 - 33
  40.       end if
  41.       updateStage()
  42.     end repeat
  43.   else
  44.     userAlert("You can only explore Islam in this demonstration version of Sources of Faith.")
  45.   end if
  46. end
  47.  
  48. on ChooseReligion religionNum
  49.   global religion, dontDoMe
  50.   set the puppet of sprite 24 to 1
  51.   set the locH of sprite 24 to 800
  52.   set the locH of sprite 23 to 800
  53.   set dontDoMe to 1
  54.   if religionNum < 1 then
  55.     puppetSprite(17, 1)
  56.     puppetSprite(21, 1)
  57.     puppetSprite(22, 1)
  58.     set the locH of sprite 17 to 800
  59.     set the locH of sprite 19 to 800
  60.     set the locV of sprite 20 to 800
  61.     set the locH of sprite 21 to 800
  62.     set the locV of sprite 22 to 800
  63.     set the castNum of sprite 18 to 452
  64.     set dontDoMe to 0
  65.     return religion
  66.   else
  67.     if religionNum = 1 then
  68.       return "Anim"
  69.     else
  70.       if religionNum = 2 then
  71.         return "Budd"
  72.       else
  73.         if religionNum = 3 then
  74.           return "Chri"
  75.         else
  76.           if religionNum = 4 then
  77.             return "Hind"
  78.           else
  79.             if religionNum = 5 then
  80.               return "Isla"
  81.             else
  82.               if religionNum = 6 then
  83.                 return "Juda"
  84.               else
  85.                 if religionNum = 7 then
  86.                   return "Tao"
  87.                 end if
  88.               end if
  89.             end if
  90.           end if
  91.         end if
  92.       end if
  93.     end if
  94.   end if
  95. end
  96.  
  97. on ChooseSubject subjectNumber
  98.   global Subject, dontDoMe
  99.   set subjectNumber to subjectNumber + 1
  100.   if subjectNumber < 9 then
  101.     set the height of sprite 20 to 46
  102.     set the width of sprite 20 to 46
  103.     set the locH of sprite 20 to the locH of sprite 20
  104.   else
  105.     set the width of sprite 20 to 70
  106.     set the height of sprite 20 to 70
  107.   end if
  108.   if subjectNumber = 1 then
  109.     return "Gods"
  110.   else
  111.     if subjectNumber = 2 then
  112.       return "life"
  113.     else
  114.       if subjectNumber = 3 then
  115.         return "Ethi"
  116.       else
  117.         if subjectNumber = 4 then
  118.           return "cult"
  119.         else
  120.           if subjectNumber = 5 then
  121.             return "fest"
  122.           else
  123.             if subjectNumber = 6 then
  124.               return "wher"
  125.             else
  126.               if subjectNumber = 7 then
  127.                 return "vari"
  128.               else
  129.                 if subjectNumber = 8 then
  130.                   return "intr"
  131.                 else
  132.                   if (subjectNumber = 9) or (subjectNumber = 10) then
  133.                     if dontDoMe = 1 then
  134.                       set Subject to "bla"
  135.                       return Subject
  136.                     else
  137.                       if dontDoMe = 0 then
  138.                         return Subject
  139.                       end if
  140.                     end if
  141.                   end if
  142.                 end if
  143.               end if
  144.             end if
  145.           end if
  146.         end if
  147.       end if
  148.     end if
  149.   end if
  150. end
  151.  
  152. on checkWhereIam
  153.   global IdleReligion, bgSound, OnorOff
  154.   if (OnorOff = 1) and (soundBusy(1) = 0) then
  155.     sound playFile 1, string(bgSound)
  156.   end if
  157.   if the castNum of sprite 18 = 449 then
  158.     if IdleReligion = "Anim" then
  159.       set whichReligion to 1
  160.     else
  161.       if IdleReligion = "Budd" then
  162.         set whichReligion to 2
  163.       else
  164.         if IdleReligion = "Chri" then
  165.           set whichReligion to 3
  166.         else
  167.           if IdleReligion = "Hind" then
  168.             set whichReligion to 4
  169.           else
  170.             if IdleReligion = "Isla" then
  171.               set whichReligion to 5
  172.             else
  173.               if IdleReligion = "Juda" then
  174.                 set whichReligion to 6
  175.               else
  176.                 if IdleReligion = "Tao" then
  177.                   set whichReligion to 7
  178.                 else
  179.                   set whichReligion to 0
  180.                 end if
  181.               end if
  182.             end if
  183.           end if
  184.         end if
  185.       end if
  186.     end if
  187.     if whichReligion > 0 then
  188.       sizeMe()
  189.       set the locH of sprite 20 to the left of sprite 18 + (78 * whichReligion) - 12
  190.     else
  191.       set the locH of sprite 20 to 800
  192.     end if
  193.   end if
  194. end
  195.  
  196. on sizeMe
  197.   set the castNum of sprite 20 to 451
  198.   set the foreColor of sprite 20 to 249
  199.   set the width of sprite 20 to 73
  200.   set the height of sprite 20 to 73
  201.   set the locV of sprite 20 to 403
  202. end
  203.  
  204. on textFlipper
  205.   set it to the locH of sprite 24
  206.   if the locH of sprite 24 > 700 then
  207.     set the puppet of sprite 24 to 1
  208.     set the locH of sprite 24 to 115
  209.     set the locV of sprite 24 to 32
  210.     set the locH of sprite 23 to 115
  211.     set the puppet of sprite 17 to 1
  212.     set the castNum of sprite 17 to 461
  213.     set the locH of sprite 17 to 43
  214.     set the locV of sprite 17 to 168
  215.   else
  216.     if the locH of sprite 24 < 800 then
  217.       set the puppet of sprite 24 to 1
  218.       set the locH of sprite 24 to 800
  219.       set the locH of sprite 23 to 800
  220.       set the castNum of sprite 17 to 454
  221.       set the locH of sprite 17 to 43
  222.     end if
  223.   end if
  224.   updateStage()
  225. end
  226.  
  227. on Textoid textFieldNum
  228.   set the castNum of sprite 24 to textFieldNum
  229.   textFlipper()
  230. end
  231.  
  232. on glossary glossWord
  233.   global bodyOfText, label, default, gloss_texts, glossList
  234.   set glossWord to lowercaseWord(unpossessive(trimWord(glossWord)))
  235.   if glossWord <> EMPTY then
  236.     cursor(4)
  237.     if glossList = EMPTY then
  238.       set glossList to getFileContent(gloss_texts & "SofIndex.txt")
  239.     end if
  240.     set glossFile to wordIsInGlossary(glossWord, glossList)
  241.     if glossFile <> EMPTY then
  242.       set glossPath to gloss_texts & glossFile
  243.       set glossDef to getFileContent(glossPath)
  244.       set the itemDelimiter to TAB
  245.       set glossWord to item 1 of glossDef
  246.       delete item 1 of glossDef
  247.       set the itemDelimiter to ","
  248.       glossAlert(glossWord, glossDef)
  249.     else
  250.       set glossWord to makeWordNotPlural(glossWord)
  251.       if glossWord <> EMPTY then
  252.         glossary(glossWord, EMPTY)
  253.       end if
  254.     end if
  255.     cursor(-1)
  256.   end if
  257. end
  258.  
  259. on getFileContent fileName
  260.   set the trace to 1
  261.   set filer to FileIO(mnew, "read", fileName)
  262.   set fileBuffer to EMPTY
  263.   repeat while 1
  264.     filer(mReadToken, EMPTY, RETURN)
  265.     set fileLine to trimString(the result)
  266.     if fileLine = EMPTY then
  267.       exit repeat
  268.       next repeat
  269.     end if
  270.     put fileLine & RETURN after fileBuffer
  271.   end repeat
  272.   filer(mdispose)
  273.   set the trace to 0
  274.   return fileBuffer
  275. end
  276.  
  277. on lowercaseWord TheWord
  278.   if TheWord <> EMPTY then
  279.     set wordLen to length(TheWord)
  280.     repeat with i = 1 to wordLen
  281.       set ascii to charToNum(char i of TheWord)
  282.       if (ascii >= 65) and (ascii <= 90) then
  283.         set ascii to ascii + 32
  284.         put numToChar(ascii) into char i of TheWord
  285.       end if
  286.     end repeat
  287.   end if
  288.   return TheWord
  289. end
  290.  
  291. on makeWordNotPlural TheWord
  292.   if TheWord <> EMPTY then
  293.     set wordLen to length(TheWord)
  294.     if "Ss" contains char wordLen of TheWord then
  295.       delete char wordLen of TheWord
  296.     else
  297.       set TheWord to EMPTY
  298.     end if
  299.   end if
  300.   return TheWord
  301. end
  302.  
  303. on unpossessive TheWord
  304.   if TheWord <> EMPTY then
  305.     set wordLen to length(TheWord)
  306.     if "Ss" contains char wordLen of TheWord then
  307.       if "'`¬¥‚Äò‚Äô¬≤" contains char wordLen - 1 of TheWord then
  308.         delete char wordLen of TheWord
  309.         delete char wordLen - 1 of TheWord
  310.       end if
  311.     end if
  312.   end if
  313.   return TheWord
  314. end
  315.  
  316. on wordIsInGlossary TheWord, theList
  317.   set wordFile to EMPTY
  318.   if (TheWord <> EMPTY) and (theList <> EMPTY) then
  319.     set lineCount to the number of lines in theList
  320.     set the itemDelimiter to TAB
  321.     if lineCount = 1 then
  322.       if item 1 of line 1 of theList = TheWord then
  323.         set wordFile to item 2 of line 1 of theList
  324.       end if
  325.     else
  326.       if lineCount <= 8 then
  327.         repeat with i = 1 to lineCount
  328.           if item 1 of line i of theList = TheWord then
  329.             set wordFile to item 2 of line i of theList
  330.             exit repeat
  331.           end if
  332.         end repeat
  333.       else
  334.         set l to 1
  335.         set h to lineCount
  336.         repeat while l <= h
  337.           set m to (l + h) / 2
  338.           if TheWord < item 1 of line m of theList then
  339.             set h to m - 1
  340.             next repeat
  341.           end if
  342.           if TheWord > item 1 of line m of theList then
  343.             set l to m + 1
  344.             next repeat
  345.           end if
  346.           set wordFile to item 2 of line m of theList
  347.           exit repeat
  348.         end repeat
  349.       end if
  350.     end if
  351.     set the itemDelimiter to ","
  352.   end if
  353.   return wordFile
  354. end
  355.  
  356. on trimWord TheWord
  357.   repeat while TheWord <> EMPTY
  358.     set ascii to charToNum(char 1 of TheWord)
  359.     if ((ascii >= 65) and (ascii <= 90)) or ((ascii >= 97) and (ascii <= 122)) then
  360.       exit repeat
  361.       next repeat
  362.     end if
  363.     delete char 1 of TheWord
  364.   end repeat
  365.   repeat while TheWord <> EMPTY
  366.     set wordLen to length(TheWord)
  367.     set ascii to charToNum(char wordLen of TheWord)
  368.     if ((ascii >= 65) and (ascii <= 90)) or ((ascii >= 97) and (ascii <= 122)) then
  369.       exit repeat
  370.       next repeat
  371.     end if
  372.     delete char wordLen of TheWord
  373.   end repeat
  374.   return TheWord
  375. end
  376.  
  377. on trimString theStr
  378.   repeat while theStr <> EMPTY
  379.     if charToNum(char 1 of theStr) <= 32 then
  380.       delete char 1 of theStr
  381.       next repeat
  382.     end if
  383.     exit repeat
  384.   end repeat
  385.   repeat while theStr <> EMPTY
  386.     set strLen to length(theStr)
  387.     if charToNum(char strLen of theStr) <= 32 then
  388.       delete char strLen of theStr
  389.       next repeat
  390.     end if
  391.     exit repeat
  392.   end repeat
  393.   return theStr
  394. end
  395.  
  396. on fatalError str
  397.   global bodyOfText, label, default
  398.   set label to "Fatal Error"
  399.   set default to RETURN & RETURN & str
  400.   if the machineType < 256 then
  401.     Dialog("modal", "glossary", "from label,from default,cancel,default")
  402.   else
  403.     alert(label & RETURN & default)
  404.   end if
  405.   reallyQuit()
  406. end
  407.  
  408. on userAlert str
  409.   global bodyOfText, label, default
  410.   set label to "Sources of Faith"
  411.   set default to RETURN & RETURN & str
  412.   if the machineType < 256 then
  413.     Dialog("modal", "glossary", "from label,from default,cancel,default")
  414.   else
  415.     alert(label & RETURN & default)
  416.   end if
  417. end
  418.  
  419. on glossAlert TheWord, theDef
  420.   global bodyOfText, label, default
  421.   set label to TheWord
  422.   set default to theDef
  423.   if the machineType < 256 then
  424.     Dialog("modal", "glossary", "from label,from default,cancel,default")
  425.   else
  426.     alert(label & ":" && default)
  427.   end if
  428. end
  429.